<!-- Modal -->
<div id="frm-post-popup" class="white-popup" style="max-width: 745px">
    <div class="weibo_post_box">
        <h2>邀请好友</h2>

        <div class="aline" style="margin-bottom: 10px"></div>
        <div class="row">
            <div class="col-xs-12" style="text-align: center">
                <span class="col-xs-12" style="color: red;padding: 10px;">双击左边选择好友到右边已选择，双击右边已选择的好友取消选择</span>

                <div class="col-xs-12" style="text-align: center">

                    <select class="before_select" size="10">
                        <volist name="friends" id="friend">
                            <option value="{$friend.uid}" title="{$friend.nickname}">{$friend.nickname}</option>
                        </volist>
                    </select>
                    <a class="btn btn-primary select_all" style="margin-top: -180px">选择全部</a>
                    <select class="after_select" size="10">
                    </select>
                    <a class="btn btn-primary sure_invite" style="margin-top: -180px">确认邀请</a>
                </div>

            </div>
        </div>

        <button title="Close (Esc)" type="button" class="mfp-close" style="color: #333;">×</button>
    </div>
</div>
<!-- /.modal -->
<style>
    .before_select, .after_select {
        width: 200px;
    }
</style>

<script>
    $(function () {
        $('.before_select option').dblclick(function () {
            $('.after_select option[value="' + $(this).val() + '"]').remove();
            $('.after_select').append($(this).clone())
            bind_after_select()
        })

        $('.select_all').click(function () {
            $('.after_select option').remove();
            $('.after_select').append($('.before_select option').clone())
            bind_after_select()
        })
        function bind_after_select() {
            $('.after_select option').unbind('dblclick');
            $('.after_select option').dblclick(function () {
                $(this).remove();
            })
        }

        $('.sure_invite').click(function () {
            var uids = new Array(); //定义数组
            $('.after_select option').each(function () {
                uids.push($(this).val());
            })
            var group_id = "{$group_id}";
            $.post(U('group/index/group_invite'), {uids: uids, group_id: group_id}, function (res) {
                if (res.status) {
                    toast.success(res.info);
                    $('.mfp-close').click();
                }
                else {
                    toast.error(res.info);
                }
            })


        })

    })
</script>